package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.Kehu;
import cn.gson.boot.model.pojos.Sell;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.math.BigDecimal;

public interface SellDao extends CrudRepository<Sell,Integer> {
    //统计图查询销售费用的员工分布
    @Query(nativeQuery = true,value = "select  count(*) from sell_ where Sell_name=?1")
    public Integer kehufuzeren(String  FZ);

    //统计图查询客户费用金额前三名
    @Query(nativeQuery = true,value = "select  sum(Sell_money) from  sell_ where k_id=?1 and  sell_condition = '同意'")
    public BigDecimal kehukhfy(Kehu kehu);


    //审核
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update sell_ set Sell_condition=?1 where Sell_id=?2")
    public void shenheBaoJiaDan(String sh,Integer qId);
}

